﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GUI
{
    public partial class qlnsGUI : Form
    {
        UserControl _ctr;

        public qlnsGUI()
        {
            InitializeComponent();
            _ctr = null;
        }

        private void Mn_LapPhieu_NhapSach_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.LapPhieu.NhapSachGUI();
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void Mn_LapPhieu_BanSach_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.LapPhieu.BanSachGUI();
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void Mn_LapPhieu_ThuTien_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.LapPhieu.ThuTienGUI();
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void Mn_BaoCao_TonThang_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.BaoCao.TonGUI();
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void Mn_BaoCao_CongNoThang_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.BaoCao.NoGUI();
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void Mn_CapNhat_QuiDinh_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.TraCuu_Update.QuiDinhGUI();
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void Mn_CapNhat_Sach_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.TraCuu_Update.SachGUI(true,null);
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void Mn_CapNhat_KhachHang_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.TraCuu_Update.KhachHangGUI(true,null);
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void Mn_TimKiem_Sach_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.TraCuu_Update.SachGUI(false,null);
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void Mn_TimKiem_KhachHang_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.TraCuu_Update.KhachHangGUI(false,null);
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void Mn_TimKiem_PhieuThu_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.TraCuu_Update.PhieuThuGUI();
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void Mn_TimKiem_BanSach_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.TraCuu_Update.BanSachGUI();
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void Mn_TimKiem_NhapSach_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.TraCuu_Update.NhapSachGUI();
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void Mn_ThemMoi_Sach_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.ThemMoi.SachGUI();
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void Mn_ThemMoi_KhachHang_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.ThemMoi.KhachHangGUI();
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void qlnsGUI_Load(object sender, EventArgs e)
        {
             Mn_TimKiem_Sach_Click(null, null);
        }

        private void SetTittle()
        {
            this.Text = ((GUI.UctrlGUI)_ctr).getName();
        }

        public static Form isOpenForm(Type formtype)
        {
            foreach (Form frm in Application.OpenForms)
                if (frm.GetType() == formtype)
                    return frm;
            return null;
        }

        private void Mn_TimKiem_BaoCaoTon_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.TraCuu_Update.BaoCaoTonGUI();
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }

        private void Mn_TimKiem_BaoCaoNo_Click(object sender, EventArgs e)
        {
            _ctr = new GUI.TraCuu_Update.BaoCaoNoGUI();
            pnl_Main.Controls.Clear();
            pnl_Main.Controls.Add(_ctr);

            SetTittle();
        }
    }
}
